home *** CD-ROM | disk | FTP | other *** search
/ Aminet 37 / Aminet 37 (2000)(Schatztruhe)[!][Jun 2000].iso / Aminet / dev / lang / sofa.lha / sofa / smalleiffel / lib_std / counter.e < prev    next >
Text File  |  2000-03-25  |  1KB  |  49 lines

  1. -- This file is  free  software, which  comes  along  with  SmallEiffel. This
  2. -- software  is  distributed  in the hope that it will be useful, but WITHOUT 
  3. -- ANY  WARRANTY;  without  even  the  implied warranty of MERCHANTABILITY or
  4. -- FITNESS  FOR A PARTICULAR PURPOSE. You can modify it as you want, provided
  5. -- this header is kept unaltered, and a notification of the changes is added.
  6. -- You  are  allowed  to  redistribute  it and sell it, alone or as a part of 
  7. -- another product.
  8. --          Copyright (C) 1994-98 LORIA - UHP - CRIN - INRIA - FRANCE
  9. --            Dominique COLNET and Suzanne COLLIN - colnet@loria.fr 
  10. --                       http://SmallEiffel.loria.fr
  11. --
  12. class COUNTER
  13. --
  14. -- Simple counter object (useful as a once function).
  15. --
  16. feature
  17.  
  18.    value: INTEGER;
  19.      -- The `value' of the counter.
  20.  
  21.    increment is
  22.       do
  23.          value := value + 1;
  24.       ensure
  25.          value = 1 + old value
  26.       end;
  27.  
  28.    decrement is
  29.       do
  30.          value := value - 1;
  31.       ensure
  32.          value + 1 = old value
  33.       end;
  34.  
  35.    reset is
  36.       do
  37.          value := 0;
  38.       ensure
  39.          value = 0
  40.       end;
  41.  
  42.    append_in(buffer: STRING) is
  43.      -- Append the `value' of the counter in the `buffer'.
  44.       do
  45.          value.append_in(buffer);
  46.       end;
  47.  
  48. end -- COUNTER
  49.